ticket=Object.new
def ticket.date
    "01/02/03"
end

def ticket.venue
    "Town Hall"
end

def ticket.event
    "Author's reading"
end

def ticket.performer
    "Mark Twain"
end

def ticket.seat
    "Second Balcony, row J,seat 12"
end

def ticket.price
    5.50
end

def ticket.availability_status
    "sold"
end

def ticket.available?
    false
end

print "The ticket is on "
print ticket.date
print " at "
print ticket.venue
print " for "
puts ticket.event
print "performer is "
puts ticket.performer
print "seat is "
puts ticket.seat
print "price is "
puts ticket.price

#字符串插值
puts "This ticket is for: #{ticket.event},at #{ticket.venue}." + 
    "The performer is #{ticket.performer}." + 
    "The seat is #{ticket.seat}, " +
    "and it costs $#{"%.2f" % ticket.price}"

#object_id
obj = Object.new
puts "The id of obj is #{obj.object_id}"
str = "Stirngs are objects too"
puts "The id of the string object str is #{str.object_id}"
puts "And the id of the integer 100 is #{100.object_id}"
#response_to查询对象的能力
if obj.respond_to?("talk")
    obj.talk
else 
    puts "Sorry, the object doensn't understand the 'talk' message."
end

puts "Information desired"
request = gets.chomp
#send_to
if ticket.respond_to?(request)
    puts ticket.send(request)
else
    puts "No such information available"
end
#必选参数和可选参数
def two_or_more(a,b,*c)
    puts "I require two or more arguments!"
    puts "And sure enough,I got:"
    p a,b,c
end
two_or_more(1,2,3,4,5)

str = 'Hello'
abc = str
str = "Goodbye"
puts str
puts abc
